package com.lanou.bookstore.user.service;


import com.lanou.bookstore.user.dao.RegisterDao;
import com.lanou.bookstore.user.domain.User;
import com.lanou.bookstore.util.JDBCUtil;

public class RegisterService {
    private RegisterDao registerDao = new RegisterDao();

    public boolean register(User user) {
        JDBCUtil.begin();// 开启事务
        if (!registerDao.hasThisName(user.getUsername())) {
            JDBCUtil.closeConn();// 关闭连接
            return registerDao.register(user);
        }
        JDBCUtil.closeConn();// 关闭连接
        return false;
    }
}
